﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BangleCMS.Model;
using BangleCMS.BLL;

public partial class System_Page_PageModify : BasePage
{
    #region 属性

    /// <summary>
    /// Action
    /// </summary>
    private string PageCode
    {
        get
        {
            return ViewState["PageCode"] == null ? "" : ViewState["PageCode"].ToString();
        }
        set
        {
            ViewState["PageCode"] = value;
        }
    }

    #endregion

    #region 加载
    protected void Page_Load(object sender, EventArgs e)
    {
        //检验用户权限
        //base.CheckUserPermission("001001");
        if (!IsPostBack)
        {
            PageCode = base.ParseQueryString("PageCode", "");
            if (PageCode == "")
            {
                base.Alert("加载错误！");
            }
            getDate(PageCode);
        }
    }
    #endregion

    #region 加载数据
    private void getDate(string pageCode)
    {
        try
        {
            t_page model = new t_page();
            t_pageBLL bll = new t_pageBLL();
            model = bll.GetModel(pageCode);
            if (model == null)
            {
                base.Alert("加载错误！");
            }
            //this.lab_PageName.Text = model.PageName;
            ////this.txt_Title.Text = model.Title;
            //this.lab_Title.Text = model.Title;
            //this.Editor.Text = model.Content;
        }
        catch (Exception ex)
        {
        }
    }
    #endregion

    #region 提交
    protected void btn_Submit_Click(object sender, EventArgs e)
    {
        #region 修改
        try
        {
            t_page model = new t_page();
            t_pageBLL bll = new t_pageBLL();

            model = bll.GetModel(PageCode);

            if (model == null)
            {
                base.Alert("操作失败！");
                return;
            }

            //model.PageName = this.txt_Title.Text.Trim();
            //model.Content = this.Editor.Text;

            model.UpdateUser = base.CurrentSession.UserID;
            model.UpdateDate = DateTime.Now;
            bll.Update(model);

            base.Alert("操作成功！");
        }
        catch (Exception ex)
        {
            base.Alert("操作失败！");
            //throw ex;
        }
        #endregion
    }
    #endregion
}
